{include file="public/header" /}
<body>
  <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
      <label class="layui-form-label">名称</label>
      <div class="layui-input-inline">
        <input type="text" lay-verify="required" name="name" value="{$data.name|default=''}" autocomplete="on" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">顶级分类</label>
      {notempty name="data['category_list']"}
      <div class="layui-input-inline">
        <select name="top_id"  lay-filter="top_id" lay-verify="required">
          <option value="0">顶级分类</option>
          {notempty name="data.top_id"}
            {volist name="data['category_list']" id="vo"}
            <option value="{$vo.id}" {notempty name="data.top_id"}{eq name="data.top_id" value="$vo.id"}selected{/eq}{/notempty}>{$vo.name}</option>
            {/volist}
          {else /}
            {volist name="data['category_list']" id="vo"}
            <option value="{$vo.id}" {notempty name="data.parent_id"}{eq name="data.parent_id" value="$vo.id"}selected{/eq}{/notempty}>{$vo.name}</option>
            {/volist}
          {/notempty}
        </select>
      </div>
      {/notempty}
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">岗位分类</label>
      <div class="layui-input-block" id="parent_id">
        {notempty name="data.category_list_child"}
          {volist name="data.category_list_child" id="vvo"}
            {if $data.top_id == 0}
              <input type="radio" name="parent_id" value="{$vvo.id}" title="{$vvo.name}" {eq name="data.id" value="$vvo.id"}checked{/eq}>
            {else /}
              <input type="radio" name="parent_id" value="{$vvo.id}" title="{$vvo.name}" {eq name="data.parent_id" value="$vvo.id"}checked{/eq}>
            {/if}
          {/volist}
        {/notempty}
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">排序id</label>
      <div class="layui-input-inline">
        <input type="text" name="sort" {notempty name="data.sort"}value="{$data.sort}"{else /}value="{:sort_id('job_category')}"{/notempty} class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">岗位级别</label>
      <div class="layui-input-block">
        {notempty name="$data.level"}
          <input type="radio" name="level" value="1" title="一级" disabled />
          <input type="radio" name="level" value="{$data.level}" title="二级" {eq name="data.level" value="2"}checked{/eq}>
          <input type="radio" name="level" value="{$data.level}" title="三级" {eq name="data.level" value="3"}checked{/eq}>
        {else /}
          <input type="radio" name="level" value="1" title="一级" />
          <input type="radio" name="level" value="2" title="二级" />
          <input type="radio" name="level" value="3" title="三级" />
        {/notempty}
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">热招岗位</label>
      <div class="layui-input-inline">
        <input type="checkbox" name="is_hot" lay-skin="switch" lay-filter="switchHot" lay-text="热门|非热门" {notempty name="data.is_hot"}{eq name="data.is_hot" value="1"}checked{/eq}{else/}{eq name="data.is_hot|default=''" value=""}{/eq}{/notempty} />
      </div>
    </div>
    {notempty name="$data.create_time"}
    <div class="layui-form-item">
      <label class="layui-form-label">最近更新</label>
      <div class="layui-input-block">
        <input type="text" class="layui-input" value="{$data.create_time|date='Y-m-d T'}" disabled="" />
      </div>
    </div>
    {/notempty}
    <div class="layui-form-item layui-hide">
      <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="添加">
      <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="编辑">
    </div>
    <input type="hidden" name="id" id="id" value="{$data.id|default=''}" />
  </div>
  <script>
  layui.config({
    base: '__config__/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form'], function(){
    var $ = layui.$
    ,form = layui.form;

    //获取主栏目下的子栏目
    form.on('select(top_id)',function(data){
      var top_id = $("select").val();
      $.ajax({
        url:"{:url('job/secondCategory')}",  //请求地址
        type: "POST", //请求方式
        dataType: "JSON", //返回数据类型
        data: {top_id: top_id}, //发送的参数
        success:function(data){
          var proHtml = '';
          for(var o in data){
            proHtml += '<input type="radio" name="parent_id" value="' + data[o].id +  '" title="'+ data[o].name +'">';
          }
          $('#parent_id').html(proHtml);
          form.render();
        },
        error:function(){
          alert("error"); //失败执行的方法
        }
      })
    });
  })
  </script>
</body>
</html>